package com.devosaurusrex.simpleflashcards;

import java.io.File;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class FileSelectionAdapter extends ArrayAdapter<File>
{

    private Context context;
    private File [] files;
    public FileSelectionAdapter(Context context, int resource, File[] files)
    {
        super(context, R.layout.file_chooser_row, files);
        this.files = files;
        this.context = context;
    }
    @Override
    public View getView(int position, View convertView, ViewGroup parent)
    {
        LayoutInflater li = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View v = li.inflate(R.layout.file_chooser_row, parent, false);
        TextView top = (TextView)v.findViewById(R.id.file_chooser_row_top);
        TextView bot = (TextView)v.findViewById(R.id.file_chooser_row_bot);
        top.setText(files[position].getName());
        bot.setText(files[position].isDirectory() ? "dir" : "file");
        v.setTag(files[position]);
        return v;
    }

    
}
